﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using EEGWin.model;
using easysql;

namespace EEGWin.dao
{
    public class UserDao:BaseDao
    {

        public void addRec(UserModel userModel,ScanDataModel scanDataModel)
        {

            using(BaseDatabase db = dh.CreateDatabaseAndOpen())
            {
                db.BeginTransaction();
                db.Add_AutoSetId<UserModel>("user", userModel);
                scanDataModel.userId = userModel.id;
                db.Add("scanData", scanDataModel);
                db.CommitTranscation();

            }
        }
        public List<UserModel> queryByPage(int page,int rows,out int total)
        {
            return dh.QueryByPage<UserModel>("user", null, page, rows, out total,Restrain.OrderDesc("id"));
        }

        public void delByIds(String ids)
        {
            dh.Execute("delete from user where id in (" + ids + ")");
        }

        public UserModel queryById(int id)
        {
            return dh.QueryById<UserModel>("user", id);
        }


    }
}
